package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PartyCourseCertificate;
import com.ruoyi.system.service.IPartyCourseCertificateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党课结业证书Controller
 * 
 * @author ruoyi
 * @date 2025-10-16
 */
@RestController
@RequestMapping("/system/certificate")
public class PartyCourseCertificateController extends BaseController
{
    @Autowired
    private IPartyCourseCertificateService partyCourseCertificateService;

    /**
     * 查询党课结业证书列表
     */
    //("@ss.hasPermi('system:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(PartyCourseCertificate partyCourseCertificate)
    {
        startPage();
        List<PartyCourseCertificate> list = partyCourseCertificateService.selectPartyCourseCertificateList(partyCourseCertificate);
        return getDataTable(list);
    }

    /**
     * 导出党课结业证书列表
     */
    //("@ss.hasPermi('system:certificate:export')")
    @Log(title = "党课结业证书", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PartyCourseCertificate partyCourseCertificate)
    {
        List<PartyCourseCertificate> list = partyCourseCertificateService.selectPartyCourseCertificateList(partyCourseCertificate);
        ExcelUtil<PartyCourseCertificate> util = new ExcelUtil<PartyCourseCertificate>(PartyCourseCertificate.class);
        util.exportExcel(response, list, "党课结业证书数据");
    }

    /**
     * 获取党课结业证书详细信息
     */
    //("@ss.hasPermi('system:certificate:query')")
    @GetMapping(value = "/{certificateId}")
    public AjaxResult getInfo(@PathVariable("certificateId") Long certificateId)
    {
        return success(partyCourseCertificateService.selectPartyCourseCertificateByCertificateId(certificateId));
    }

    /**
     * 新增党课结业证书
     */
    //("@ss.hasPermi('system:certificate:add')")
    @Log(title = "党课结业证书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PartyCourseCertificate partyCourseCertificate)
    {
        return toAjax(partyCourseCertificateService.insertPartyCourseCertificate(partyCourseCertificate));
    }

    /**
     * 修改党课结业证书
     */
    //("@ss.hasPermi('system:certificate:edit')")
    @Log(title = "党课结业证书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PartyCourseCertificate partyCourseCertificate)
    {
        return toAjax(partyCourseCertificateService.updatePartyCourseCertificate(partyCourseCertificate));
    }

    /**
     * 删除党课结业证书
     */
    //("@ss.hasPermi('system:certificate:remove')")
    @Log(title = "党课结业证书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{certificateIds}")
    public AjaxResult remove(@PathVariable Long[] certificateIds)
    {
        return toAjax(partyCourseCertificateService.deletePartyCourseCertificateByCertificateIds(certificateIds));
    }
}
